//
// Created by feng on 19-3-28.
//
#ifndef SOLARENERGY_CHIER_RANDOMGENERATOR_CUH
#define SOLARENERGY_CHIER_RANDOMGENERATOR_CUH

#include <curand.h>

#include <random>

#include <driver_types.h>

namespace solar::cuda
{
    class RandomGenerator
    {
        public:
            // static unsigned int seed
            static curandGenerator_t gen;

            static std::default_random_engine generator;

            // init the seed
            static void initSeed();

            static void initSeed(unsigned int seed);

            static void initCudaRandGenerator();

            // destroy the cuda random generator
            static void destroyCudaRandGenerator();

            //[0 , 1]
            static auto cpuUniform(float* h_0_1_array, int array_length) -> bool;
            static auto gpuUniform(float* d_0_1_array, int array_length) -> bool;
            static auto cpuGaussian(float* h_0_1_array, float mean, float stddev,
                                     int array_length) -> bool;
            static auto gpuGaussian(float* d_0_1_array, float mean, float stddev,
                                     int array_length) -> bool;

            //[low_threshold, high_threshold]
            static auto cpuUniform(int* h_min_max_array, int low_threshold, int high_threshold,
                                    int array_length) -> bool;
            static auto gpuUniform(int* d_min_max_array, int low_threshold, int high_threshold,
                                    int array_length, cudaStream_t stream = nullptr) -> bool;
    };
} // namespace solar::cuda

#endif // SOLARENERGY_CHIER_RANDOMGENERATOR_CUH
